package com.duke.shaking.storage;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class OwnerManager{
	
	public static final String MOBILE = "mobile";
	public static final String PASSWORD = "password";
	public static final String AVATARURL = "avatarUrl";
	public static final String NEVERREG = "neverReg";
	
	private static OwnerManager ownerManager;
	private SharedPreferences sp;
	
	public static OwnerManager shared() {
		return ownerManager;
	}

	public static void createShared(Context context) {
		if (ownerManager == null) {
			ownerManager = new OwnerManager(context);
		}
	}
	
	public OwnerManager(Context context) {
		sp = context.getSharedPreferences("com.duke.shaking", 
				Context.MODE_PRIVATE);
	}
	
	public String getMobile () {
		return sp.getString(MOBILE, null);
	}
	
	public void saveMobile(String mobile) {
		Editor editor = sp.edit();
		editor.putString(MOBILE, mobile);
		editor.commit();
	}
	
	public String getPassword() {
		return sp.getString(PASSWORD, null);
	}
	
	public void savePassword(String password) {
		Editor editor = sp.edit();
		editor.putString(PASSWORD, password);
		editor.commit();
	}
	
	public boolean neverReg() {
		return sp.getBoolean(NEVERREG, false);
	}
	
	public void saveHasReg(boolean hasReg) {
		Editor editor = sp.edit();
		editor.putBoolean(NEVERREG, hasReg);
		editor.commit();
	}
	
	public String getAvatarUrl() {
		return sp.getString(AVATARURL, null);
	}
	
	public void saveAvatarUrl(String avatarUrl) {
		Editor editor = sp.edit();
		editor.putString(AVATARURL, avatarUrl);
		editor.commit();
	}
}
